package com.chz.SupermarketMS.service;

import com.chz.SupermarketMS.dao.PurchaseRepository;
import com.chz.SupermarketMS.entities.Purchase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurchaseService {

    @Autowired
    PurchaseRepository purchaseRepository;

    public Purchase save(Purchase purchase){
        return purchaseRepository.save(purchase);
    }

    public List<Purchase> getAll(){
        return purchaseRepository.findAll();
    }

    public Purchase findByPurchaseId(long theId) {
        return PurchaseRepository.findByPurchaseId(theId);
    }

    public void delete(Purchase thePurchase) {
        purchaseRepository.delete(thePurchase);
    }
}
